**********************************************************
*** Marsh & Mikhaylov "A Conservative Revolution:
***                   The electoral response to economic
***                    crisis in Ireland." JEPOP.
**********************************************************
***   Replication materials
**********************************************************

use data, clear

*Recoding QC5 as binary
recode QC5 (1=1) (nonmissing=0)
label define QC5new 1 "Mainly due to policies of that govt" 0 "Not mainly due to policies of that govt" 
label values QC5 QC5new

*Recoding QC6 as binary, lines up 2002 with the rest
recode QC6 (1=1) (nonmissing=0)
label define QC6new 1 "Better" 0 "Not better" 
label values QC6 QC6new

/*Recoding QC4 as three levels due to sparse cells in 2011*/
recode QC4 (1 2 = 1) (3=2) (4 5 = 3) 
label define QC4new 1 "Better" 2 "Same" 3 "Worse"
label values QC4 QC4new

/*Recoding minor parties as Other*/
gen QB4CBnew=QB4CB
recode QB4CBnew (3 = 9) (5=9) (7 = 9) 
label define QB4CBnew 1 "Fianna Fail" 2 "Fine Gael" 4 "Labour" 6 "Sinn Fein" 9 "Other"
label values QB4CBnew QB4CBnew



/*****  TABLE 3   *****/

/*2002*/
/*FF*/
mlogit QB4CBnew QC4 i.QC5 i.QC6  ffid-otherid if ines==2002, b(2)

margins, dydx(QC4 QC5 QC6) predict(outcome(1)) post
outreg2 using Table3, dec(3) ctitle(Fianna Fail) 

/*FG*/
mlogit QB4CBnew QC4 i.QC5 i.QC6  ffid-otherid if ines==2002, b(2)

margins, dydx(QC4 QC5 QC6) predict(outcome(2)) post
outreg2 using Table3, dec(3) ctitle(Fine Gael)

/*Labour*/
mlogit QB4CBnew QC4 i.QC5 i.QC6  ffid-otherid if ines==2002, b(2)

margins, dydx(QC4 QC5 QC6) predict(outcome(4)) post
outreg2 using Table3, dec(3) ctitle(Labour) 

/*SF*/
mlogit QB4CBnew QC4 i.QC5 i.QC6  ffid-otherid if ines==2002, b(2)

margins, dydx(QC4 QC5 QC6) predict(outcome(6)) post
outreg2 using Table3, dec(3) ctitle(Sinn Fein)


/*Other*/
mlogit QB4CBnew QC4 i.QC5 i.QC6  ffid-otherid if ines==2002, b(2)

margins, dydx(QC4 QC5 QC6) predict(outcome(9))




/*2007*/
/*FF*/
mlogit QB4CBnew QC4 i.QC5 i.QC6  ffid-otherid if ines==2007, b(2)

margins, dydx(QC4 QC5 QC6) predict(outcome(1)) post
outreg2 using Table3, dec(3) ctitle(Fianna Fail) 

/*FG*/
mlogit QB4CBnew QC4 i.QC5 i.QC6  ffid-otherid if ines==2007, b(2)

margins, dydx(QC4 QC5 QC6) predict(outcome(2)) post
outreg2 using Table3, dec(3) ctitle(Fine Gael)

/*Labour*/
mlogit QB4CBnew QC4 i.QC5 i.QC6  ffid-otherid if ines==2007, b(2)

margins, dydx(QC4 QC5 QC6) predict(outcome(4)) post
outreg2 using Table3, dec(3) ctitle(Labour) 

/*SF*/
mlogit QB4CBnew QC4 i.QC5 i.QC6  ffid-otherid if ines==2007, b(2)

margins, dydx(QC4 QC5 QC6) predict(outcome(6)) post
outreg2 using Table3, dec(3) ctitle(Sinn Fein)

/*Other*/
mlogit QB4CBnew QC4 i.QC5 i.QC6  ffid-otherid if ines==2007, b(2)

margins, dydx(QC4 QC5 QC6) predict(outcome(9))


/*2011*/
/*FF*/
mlogit QB4CBnew QC4 i.QC5 i.QC6  ffid-otherid if ines==2011, b(2)

margins, dydx(QC4 QC5 QC6) predict(outcome(1)) post
outreg2 using Table3, dec(3) ctitle(Fianna Fail) 

/*FG*/
mlogit QB4CBnew QC4 i.QC5 i.QC6  ffid-otherid if ines==2011, b(2)

margins, dydx(QC4 QC5 QC6) predict(outcome(2)) post
outreg2 using Table3, dec(3) ctitle(Fine Gael)

/*Labour*/
mlogit QB4CBnew QC4 i.QC5 i.QC6  ffid-otherid if ines==2011, b(2)

margins, dydx(QC4 QC5 QC6) predict(outcome(4)) post
outreg2 using Table3, dec(3) ctitle(Labour) 

/*SF*/
mlogit QB4CBnew QC4 i.QC5 i.QC6  ffid-otherid if ines==2011, b(2)

margins, dydx(QC4 QC5 QC6) predict(outcome(6)) post
outreg2 using Table3, dec(3) ctitle(Sinn Fein)

/*Other*/
mlogit QB4CBnew QC4 i.QC5 i.QC6  ffid-otherid if ines==2011, b(2)

margins, dydx(QC4 QC5 QC6) predict(outcome(9))



/*Models with party attachment only*/
mlogit QB4CBnew QC4 i.QC5 i.QC6  ffid-otherid if ines==2002, b(2)
mlogit QB4CBnew ffid-otherid if ines==2002 & e(sample), b(2)

mlogit QB4CBnew QC4 i.QC5 i.QC6  ffid-otherid if ines==2007, b(2)
mlogit QB4CBnew ffid-otherid if ines==2007 & e(sample), b(2)

mlogit QB4CBnew QC4 i.QC5 i.QC6  ffid-otherid if ines==2011, b(2)
mlogit QB4CBnew ffid-otherid if ines==2011 & e(sample), b(2)





/*****    TABLE 4  *****/

* predicting vote by left/right attitudes and policy preferences


/*2002*/
/*FF*/
mlogit QB4CBnew Q8 QB20P1 Q3P3 Q3P5 ffid-otherid if ines==2002, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(1)) post
outreg2 using Table4, dec(3) ctitle(Fianna Fail) 

/*FG*/
mlogit QB4CBnew Q8 QB20P1 Q3P3 Q3P5  ffid-otherid if ines==2002, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(2)) post
outreg2 using Table4, dec(3) ctitle(Fine Gael)

/*Labour*/
mlogit QB4CBnew Q8 QB20P1 Q3P3 Q3P5 ffid-otherid if ines==2002, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(4)) post
outreg2 using Table4, dec(3) ctitle(Labour) 

/*SF*/
mlogit QB4CBnew Q8 QB20P1 Q3P3 Q3P5 ffid-otherid if ines==2002, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(6)) post
outreg2 using Table4, dec(3) ctitle(Sinn Fein)



/*2007*/
/*FF*/
mlogit QB4CBnew Q8 QB20P1 Q3P3 Q3P5 ffid-otherid if ines==2007, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(1)) post
outreg2 using Table4, dec(3) ctitle(Fianna Fail) 

/*FG*/
mlogit QB4CBnew Q8 QB20P1 Q3P3 Q3P5  ffid-otherid if ines==2007, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(2)) post
outreg2 using Table4, dec(3) ctitle(Fine Gael)

/*Labour*/
mlogit QB4CBnew Q8 QB20P1 Q3P3 Q3P5 ffid-otherid if ines==2007, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(4)) post
outreg2 using Table4, dec(3) ctitle(Labour) 

/*SF*/
mlogit QB4CBnew Q8 QB20P1 Q3P3 Q3P5 ffid-otherid if ines==2007, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(6)) post
outreg2 using Table4, dec(3) ctitle(Sinn Fein)



/*2011-1*/
/*FF*/
mlogit QB4CBnew Q8 QB20P1 Q3P3 Q3P5 ffid-otherid if ines==2011, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(1)) post
outreg2 using Table4, dec(3) ctitle(Fianna Fail) 

/*FG*/
mlogit QB4CBnew Q8 QB20P1 Q3P3 Q3P5  ffid-otherid if ines==2011, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(2)) post
outreg2 using Table4, dec(3) ctitle(Fine Gael)

/*Labour*/
mlogit QB4CBnew Q8 QB20P1 Q3P3 Q3P5 ffid-otherid if ines==2011, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(4)) post
outreg2 using Table4, dec(3) ctitle(Labour) 

/*SF*/
mlogit QB4CBnew Q8 QB20P1 Q3P3 Q3P5 ffid-otherid if ines==2011, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(6)) post
outreg2 using Table4, dec(3) ctitle(Sinn Fein)



* add extra variables for 2011

/*2011-2*/
/*FF*/
mlogit QB4CBnew QB20P1 Q3P3 Q3P5 QB20P2 QD1 ffid-otherid if ines==2011, b(2)

margins, dydx(QB20P1 Q3P3 Q3P5 QB20P2 QD1) predict(outcome(1)) post
outreg2 using Table4, dec(3) ctitle(Fianna Fail) 

/*FG*/
mlogit QB4CBnew QB20P1 Q3P3 Q3P5 QB20P2 QD1  ffid-otherid if ines==2011, b(2)

margins, dydx(QB20P1 Q3P3 Q3P5 QB20P2 QD1 ) predict(outcome(2)) post
outreg2 using Table4, dec(3) ctitle(Fine Gael)

/*Labour*/
mlogit QB4CBnew QB20P1 Q3P3 Q3P5 QB20P2 QD1 ffid-otherid if ines==2011, b(2)

margins, dydx(QB20P1 Q3P3 Q3P5 QB20P2 QD1) predict(outcome(4)) post
outreg2 using Table4, dec(3) ctitle(Labour) 

/*SF*/
mlogit QB4CBnew QB20P1 Q3P3 Q3P5 QB20P2 QD1 ffid-otherid if ines==2011, b(2)

margins, dydx(QB20P1 Q3P3 Q3P5 QB20P2 QD1) predict(outcome(6)) post
outreg2 using Table4, dec(3) ctitle(Sinn Fein)




/*Models with party attachment only*/
mlogit QB4CBnew Q8 QB20P1 Q3P3 Q3P5 ffid-otherid if ines==2002, b(2)
mlogit QB4CBnew ffid-otherid if ines==2002 & e(sample), b(2)

mlogit QB4CBnew Q8 QB20P1 Q3P3 Q3P5 ffid-otherid if ines==2007, b(2)
mlogit QB4CBnew ffid-otherid if ines==2007 & e(sample), b(2)

mlogit QB4CBnew Q8 QB20P1 Q3P3 Q3P5 ffid-otherid if ines==2011, b(2)
mlogit QB4CBnew ffid-otherid if ines==2011 & e(sample), b(2)

mlogit QB4CBnew QB20P1 Q3P3 Q3P5 QB20P2 QD1 ffid-otherid if ines==2011, b(2)
mlogit QB4CBnew ffid-otherid if ines==2011 & e(sample), b(2)
































/************   TABLE 2A ***************/
* choice as between FF and FG only



/*2002*/
/*FF*/
mlogit QB4CBnew QC4 i.QC5 i.QC6  ffid-otherid if ines==2002 & QB4CBnew < 3, b(2)

margins, dydx(QC4 QC5 QC6) predict(outcome(1)) post
outreg2 using Table2a, dec(3) ctitle(Fianna Fail) 

/*FG*/
mlogit QB4CBnew QC4 i.QC5 i.QC6  ffid-otherid if ines==2002 & QB4CBnew < 3, b(2)

margins, dydx(QC4 QC5 QC6) predict(outcome(2)) post
outreg2 using Table2a, dec(3) ctitle(Fine Gael)




/*2007*/
/*FF*/
mlogit QB4CBnew QC4 i.QC5 i.QC6  ffid-otherid if ines==2007 & QB4CBnew < 3, b(2)

margins, dydx(QC4 QC5 QC6) predict(outcome(1)) post
outreg2 using Table2a, dec(3) ctitle(Fianna Fail) 

/*FG*/
mlogit QB4CBnew QC4 i.QC5 i.QC6  ffid-otherid if ines==2007 & QB4CBnew < 3, b(2)

margins, dydx(QC4 QC5 QC6) predict(outcome(2)) post
outreg2 using Table2a, dec(3) ctitle(Fine Gael)



/*2011*/
/*FF*/
mlogit QB4CBnew QC4 i.QC5 i.QC6  ffid-otherid if ines==2011 & QB4CBnew < 3, b(2)

margins, dydx(QC4 QC5 QC6) predict(outcome(1)) post
outreg2 using Table2a, dec(3) ctitle(Fianna Fail) 

/*FG*/
mlogit QB4CBnew QC4 i.QC5 i.QC6  ffid-otherid if ines==2011 & QB4CBnew < 3, b(2)

margins, dydx(QC4 QC5 QC6) predict(outcome(2)) post
outreg2 using Table2a, dec(3) ctitle(Fine Gael)




/************   TABLE 2B ***************/
* choice as FF + allies vs rest

gen FFa=QB4CB
recode FFa (1 5=1) (nonmissing=0)
label define FFa 1 "Fianna Fail allies" 0 "Not"
label values FFa FFa


logit FFa QC4 i.QC5 i.QC6  ffid-otherid if ines==2002
margins, dydx(QC4 QC5 QC6) post
outreg2 using Table2b, dec(3) ctitle(2002) 

logit FFa QC4 i.QC5 i.QC6  ffid-otherid if ines==2007
margins, dydx(QC4 QC5 QC6) post
outreg2 using Table2b, dec(3) ctitle(2007) 

* for 2011 put greens in with FFa
replace FFa=1 if QB4CB ==3

logit FFa QC4 i.QC5 i.QC6  ffid-otherid if ines==2011
margins, dydx(QC4 QC5 QC6) post
outreg2 using Table2b, dec(3) ctitle(2011) 




* add ANGER to model run for table 2
*  ANGER is QC10P1

mlogit QB4CBnew QC4 i.QC5 i.QC6 QC10P1 ffid-otherid if ines==2011, b(2)



* LEADER COMPETENCES FOR TABLE 3
table ines [pw=WEIGHT], c ( mean QC14P1 mean QC14P3 mean QC14P4 mean QC14P5) format(%3.1f)




/*****    TABLE 4   *****/
* Issues in 2011
* Construct multiple respose isues variable
for new issue1-issue26: gen X=0
for var issue1-issue26 \ num 1/26: replace X=1 if QB22A==Y | QB22B==Y
for new crisis econ pol: gen X=0
replace pol=1 if issue1==1 | issue2==1
replace crisis=1 if issue5==1| issue6==1|issue8==1|issue14==1
replace econ=1 if issue7==1|issue9==1|issue10==1|issue13==1|issue16==1|issue18==1 
gen other=0
replace other =1 if issue24==1 | issue3==1 | issue4==1

* Do issues matter? redo with just top 10 or so
* mlogit QB4CB ffid-sfid issue* if ines==2011 & QB4CB < 8, b(2)





/*****    TABLE PROX2   *****/
* predicting vote by left/right attitudes and policy preferences AND LR self placement



/*2002*/
/*FF*/
mlogit QB4CBnew Q8 QB20P1 Q3P3 Q3P5 QB21 ffid-otherid if ines==2002, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5 QB21) predict(outcome(1)) post
outreg2 using TableProx2, dec(3) ctitle(Fianna Fail) 

/*FG*/
mlogit QB4CBnew Q8 QB20P1 Q3P3 Q3P5 QB21 ffid-otherid if ines==2002, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5 QB21) predict(outcome(2)) post
outreg2 using TableProx2, dec(3) ctitle(Fine Gael)

/*Labour*/
mlogit QB4CBnew Q8 QB20P1 Q3P3 Q3P5 QB21 ffid-otherid if ines==2002, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5 QB21) predict(outcome(4)) post
outreg2 using TableProx2, dec(3) ctitle(Labour) 

/*SF*/
mlogit QB4CBnew Q8 QB20P1 Q3P3 Q3P5 QB21 ffid-otherid if ines==2002, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5 QB21) predict(outcome(6)) post
outreg2 using TableProx2, dec(3) ctitle(Sinn Fein)

/*2007*/
/*FF*/
mlogit QB4CBnew Q8 QB20P1 Q3P3 Q3P5 QB21 ffid-otherid if ines==2007, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5 QB21) predict(outcome(1)) post
outreg2 using TableProx2, dec(3) ctitle(Fianna Fail) 

/*FG*/
mlogit QB4CBnew Q8 QB20P1 Q3P3 Q3P5 QB21 ffid-otherid if ines==2007, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5 QB21) predict(outcome(2)) post
outreg2 using TableProx2, dec(3) ctitle(Fine Gael)

/*Labour*/
mlogit QB4CBnew Q8 QB20P1 Q3P3 Q3P5 QB21 ffid-otherid if ines==2007, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5 QB21) predict(outcome(4)) post
outreg2 using TableProx2, dec(3) ctitle(Labour) 

/*SF*/
mlogit QB4CBnew Q8 QB20P1 Q3P3 Q3P5 QB21 ffid-otherid if ines==2007, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5 QB21) predict(outcome(6)) post
outreg2 using TableProx2, dec(3) ctitle(Sinn Fein)


/*2011-1*/
/*FF*/
mlogit QB4CBnew Q8 QB20P1 Q3P3 Q3P5 QB21 ffid-otherid if ines==2011, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5 QB21) predict(outcome(1)) post
outreg2 using TableProx2, dec(3) ctitle(Fianna Fail) 

/*FG*/
mlogit QB4CBnew Q8 QB20P1 Q3P3 Q3P5 QB21 ffid-otherid if ines==2011, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5 QB21) predict(outcome(2)) post
outreg2 using TableProx2, dec(3) ctitle(Fine Gael)

/*Labour*/
mlogit QB4CBnew Q8 QB20P1 Q3P3 Q3P5 QB21 ffid-otherid if ines==2011, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5 QB21) predict(outcome(4)) post
outreg2 using TableProx2, dec(3) ctitle(Labour) 

/*SF*/
mlogit QB4CBnew Q8 QB20P1 Q3P3 Q3P5 QB21 ffid-otherid if ines==2011, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5 QB21) predict(outcome(6)) post
outreg2 using TableProx2, dec(3) ctitle(Sinn Fein)


/*2011-2*/
/*FF*/
mlogit QB4CBnew Q8 QB20P1 Q3P3 Q3P5 QB21 QB20P2 QD1 ffid-otherid if ines==2011, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5 QB21 QB20P2 QD1) predict(outcome(1)) post
outreg2 using TableProx2, dec(3) ctitle(Fianna Fail) 

/*FG*/
mlogit QB4CBnew Q8 QB20P1 Q3P3 Q3P5 QB21 QB20P2 QD1 ffid-otherid if ines==2011, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5 QB21 QB20P2 QD1) predict(outcome(2)) post
outreg2 using TableProx2, dec(3) ctitle(Fine Gael)

/*Labour*/
mlogit QB4CBnew Q8 QB20P1 Q3P3 Q3P5 QB21 QB20P2 QD1  ffid-otherid if ines==2011, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5 QB21 QB20P2 QD1) predict(outcome(4)) post
outreg2 using TableProx2, dec(3) ctitle(Labour) 

/*SF*/
mlogit QB4CBnew Q8 QB20P1 Q3P3 Q3P5 QB21 QB20P2 QD1 ffid-otherid if ines==2011, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5 QB21 QB20P2 QD1) predict(outcome(6)) post
outreg2 using TableProx2, dec(3) ctitle(Sinn Fein)


/*****    TABLE 6   *****/
* predicting left right
* be nice to have the same number of cases in both 2011 models

regress QB21 Q8 QB20P1 Q3P3 Q3P5 if ines==2002, vce(robust) 
est store e2002

regress QB21 Q8 QB20P1 Q3P3 Q3P5 if ines==2007, vce(robust) 
est store e2007

regress QB21 Q8 QB20P1 Q3P3 Q3P5 if ines==2011, vce(robust) 
est store e2011a

regress QB21 QB20P1 Q3P3 Q3P5 QB20P2 QD1 if ines==2011, vce(robust) 
est store e2011b

outreg2 [e2002 e2007 e2011a e2011b] using Table6, dec(3)



/*****    TABLE 7   *****/
* party or candidate?
svy: tab QB7A ines if QB4CB < 7 & QB7A < 3, col perc format(%3.0f) nomarg
svy: tab QB7B ines if QB4CB < 7 & QB7A < 3, col perc format(%3.0f) nomarg

gen COP=1
replace COP=2 if QB7A==1 & QB7B==2
replace COP=0 if QB7A==2 & QB7B==1


/*****    TABLE 8a   *****/
* Does left right work better for party voters

/*Recoding for party vote*/
gen QB4CBalt=QB4CB
recode QB4CBalt (3 = 8) (5=8) (7 = 9) 
label define QB4CBalt 1 "Fianna Fail" 2 "Fine Gael" 4 "Labour" 6 "Sinn Fein" 8 "Other parties" 9 "Independent"
label values QB4CBalt QB4CBalt


* predicting vote for party centred voters by left/right attitudes and policy preferences, leaving OUT party ID

/*2002*/
*Party

/*FF*/
mlogit QB4CBalt Q8 QB20P1 Q3P3 Q3P5 if ines==2002 & QB4CBalt < 9 & COP==2, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(1)) post
outreg2 using Table8a, dec(3) ctitle(Fianna Fail) 

/*FG*/
mlogit QB4CBalt Q8 QB20P1 Q3P3 Q3P5 if ines==2002 & QB4CBalt < 9 & COP==2, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(2)) post
outreg2 using Table8a, dec(3) ctitle(Fine Gael)

/*Labour*/
mlogit QB4CBalt Q8 QB20P1 Q3P3 Q3P5 if ines==2002 & QB4CBalt < 9 & COP==2, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(4)) post
outreg2 using Table8a, dec(3) ctitle(Labour) 

/*SF*/
mlogit QB4CBalt Q8 QB20P1 Q3P3 Q3P5 if ines==2002 & QB4CBalt < 9 & COP==2, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(6)) post
outreg2 using Table8a, dec(3) ctitle(Sinn Fein)


/*2007*/
/*FF*/
mlogit QB4CBalt Q8 QB20P1 Q3P3 Q3P5 if ines==2007 & QB4CBalt < 9 & COP==2, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(1)) post
outreg2 using Table8a, dec(3) ctitle(Fianna Fail) 

/*FG*/
mlogit QB4CBalt Q8 QB20P1 Q3P3 Q3P5 if ines==2007 & QB4CBalt < 9 & COP==2, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(2)) post
outreg2 using Table8a, dec(3) ctitle(Fine Gael)

/*Labour*/
mlogit QB4CBalt Q8 QB20P1 Q3P3 Q3P5 if ines==2007 & QB4CBalt < 9 & COP==2, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(4)) post
outreg2 using Table8a, dec(3) ctitle(Labour) 

/*SF*/
mlogit QB4CBalt Q8 QB20P1 Q3P3 Q3P5 if ines==2007 & QB4CBalt < 9 & COP==2, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(6)) post
outreg2 using Table8a, dec(3) ctitle(Sinn Fein)


/*2011-1*/
/*FF*/
mlogit QB4CBalt Q8 QB20P1 Q3P3 Q3P5 if ines==2011 & QB4CBalt < 9 & COP==2, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(1)) post
outreg2 using Table8a, dec(3) ctitle(Fianna Fail) 

/*FG*/
mlogit QB4CBalt Q8 QB20P1 Q3P3 Q3P5 if ines==2011 & QB4CBalt < 9 & COP==2, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(2)) post
outreg2 using Table8a, dec(3) ctitle(Fine Gael)

/*Labour*/
mlogit QB4CBalt Q8 QB20P1 Q3P3 Q3P5 if ines==2011 & QB4CBalt < 9 & COP==2, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(4)) post
outreg2 using Table8a, dec(3) ctitle(Labour) 

/*SF*/
mlogit QB4CBalt Q8 QB20P1 Q3P3 Q3P5 if ines==2011 & QB4CBalt < 9 & COP==2, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(6)) post
outreg2 using Table8a, dec(3) ctitle(Sinn Fein)


/*2011-2*/
* add extra variables for 2011

/*FF*/
mlogit QB4CBalt QB20P1 Q3P3 Q3P5 QB20P2 QD1 if ines==2011 & QB4CBalt < 9 & COP==2, b(2)

margins, dydx(QB20P1 Q3P3 Q3P5 QB20P2 QD1) predict(outcome(1)) post
outreg2 using Table8a, dec(3) ctitle(Fianna Fail) 

/*FG*/
mlogit QB4CBalt QB20P1 Q3P3 Q3P5 QB20P2 QD1 if ines==2011 & QB4CBalt < 9 & COP==2, b(2)

margins, dydx(QB20P1 Q3P3 Q3P5 QB20P2 QD1) predict(outcome(2)) post
outreg2 using Table8a, dec(3) ctitle(Fine Gael)

/*Labour*/
mlogit QB4CBalt QB20P1 Q3P3 Q3P5 QB20P2 QD1 if ines==2011 & QB4CBalt < 9 & COP==2, b(2)

margins, dydx(QB20P1 Q3P3 Q3P5 QB20P2 QD1) predict(outcome(4)) post
outreg2 using Table8a, dec(3) ctitle(Labour) 

/*SF*/
mlogit QB4CBalt QB20P1 Q3P3 Q3P5 QB20P2 QD1 if ines==2011 & QB4CBalt < 9 & COP==2, b(2)

margins, dydx(QB20P1 Q3P3 Q3P5 QB20P2 QD1) predict(outcome(6)) post
outreg2 using Table8a, dec(3) ctitle(Sinn Fein)







/*****    TABLE 8b   *****/
*Candidate

/*2002*/
/*FF*/
mlogit QB4CBalt Q8 QB20P1 Q3P3 Q3P5 if ines==2002 & QB4CBalt < 9 & COP==0, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(1)) post
outreg2 using Table8b, dec(3) ctitle(Fianna Fail) 

/*FG*/
mlogit QB4CBalt Q8 QB20P1 Q3P3 Q3P5 if ines==2002 & QB4CBalt < 9 & COP==0, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(2)) post
outreg2 using Table8b, dec(3) ctitle(Fine Gael)

/*Labour*/
mlogit QB4CBalt Q8 QB20P1 Q3P3 Q3P5 if ines==2002 & QB4CBalt < 9 & COP==0, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(4)) post
outreg2 using Table8b, dec(3) ctitle(Labour) 

/*SF*/
mlogit QB4CBalt Q8 QB20P1 Q3P3 Q3P5 if ines==2002 & QB4CBalt < 9 & COP==0, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(6)) post
outreg2 using Table8b, dec(3) ctitle(Sinn Fein)


/*2007*/
/*FF*/
mlogit QB4CBalt Q8 QB20P1 Q3P3 Q3P5 if ines==2007 & QB4CBalt < 9 & COP==0, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(1)) post
outreg2 using Table8b, dec(3) ctitle(Fianna Fail) 

/*FG*/
mlogit QB4CBalt Q8 QB20P1 Q3P3 Q3P5 if ines==2007 & QB4CBalt < 9 & COP==0, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(2)) post
outreg2 using Table8b, dec(3) ctitle(Fine Gael)

/*Labour*/
mlogit QB4CBalt Q8 QB20P1 Q3P3 Q3P5 if ines==2007 & QB4CBalt < 9 & COP==0, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(4)) post
outreg2 using Table8b, dec(3) ctitle(Labour) 

/*SF*/
mlogit QB4CBalt Q8 QB20P1 Q3P3 Q3P5 if ines==2007 & QB4CBalt < 9 & COP==0, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(6)) post
outreg2 using Table8b, dec(3) ctitle(Sinn Fein)


/*2011-1*/
/*FF*/
mlogit QB4CBalt Q8 QB20P1 Q3P3 Q3P5 if ines==2011 & QB4CBalt < 9 & COP==0, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(1)) post
outreg2 using Table8b, dec(3) ctitle(Fianna Fail) 

/*FG*/
mlogit QB4CBalt Q8 QB20P1 Q3P3 Q3P5 if ines==2011 & QB4CBalt < 9 & COP==0, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(2)) post
outreg2 using Table8b, dec(3) ctitle(Fine Gael)

/*Labour*/
mlogit QB4CBalt Q8 QB20P1 Q3P3 Q3P5 if ines==2011 & QB4CBalt < 9 & COP==0, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(4)) post
outreg2 using Table8b, dec(3) ctitle(Labour) 

/*SF*/
mlogit QB4CBalt Q8 QB20P1 Q3P3 Q3P5 if ines==2011 & QB4CBalt < 9 & COP==0, b(2)

margins, dydx(Q8 QB20P1 Q3P3 Q3P5) predict(outcome(6)) post
outreg2 using Table8b, dec(3) ctitle(Sinn Fein)


/*2011-2*/
* add extra variables for 2011

/*FF*/
mlogit QB4CBalt QB20P1 Q3P3 Q3P5 QB20P2 QD1 if ines==2011 & QB4CBalt < 9 & COP==0, b(2)

margins, dydx(QB20P1 Q3P3 Q3P5 QB20P2 QD1) predict(outcome(1)) post
outreg2 using Table8b, dec(3) ctitle(Fianna Fail) 

/*FG*/
mlogit QB4CBalt QB20P1 Q3P3 Q3P5 QB20P2 QD1 if ines==2011 & QB4CBalt < 9 & COP==0, b(2)

margins, dydx(QB20P1 Q3P3 Q3P5 QB20P2 QD1) predict(outcome(2)) post
outreg2 using Table8b, dec(3) ctitle(Fine Gael)

/*Labour*/
mlogit QB4CBalt QB20P1 Q3P3 Q3P5 QB20P2 QD1 if ines==2011 & QB4CBalt < 9 & COP==0, b(2)

margins, dydx(QB20P1 Q3P3 Q3P5 QB20P2 QD1) predict(outcome(4)) post
outreg2 using Table8b, dec(3) ctitle(Labour) 

/*SF*/
mlogit QB4CBalt QB20P1 Q3P3 Q3P5 QB20P2 QD1 if ines==2011 & QB4CBalt < 9 & COP==0, b(2)

margins, dydx(QB20P1 Q3P3 Q3P5 QB20P2 QD1) predict(outcome(6)) post
outreg2 using Table8b, dec(3) ctitle(Sinn Fein)




log close



















































/***** NOT USED BELOW *****/



/***  MARGINS PLOTS  ***/

/*2002*/
mlogit QB4CB i.QC4##i.QC5 i.QC6  ffid-pdid if ines==2002 & QB4CB < 8, b(2)
est store e2002tab2

/*margins for FF*/
*average marginal effect of covariates for voting FF

margins, dydx(QC4 QC5 QC6) predict(outcome(1))

marginsplot, recast(scatter) ytitle(Effects on probability of voting Fianna Fail) yline(0, lwidth(vthin) lcolor(red)) xtitle(Effects with respect to) xtitle(, margin(medium)) title(Average Marginal Effects with 95% CIs, justification(right)) legend(cols(1) region(lcolor(none))) xscale(range(1.5 9.5)) scheme(s1mono) subtitle(2002) saving(FFme2002, replace)


*average prediction of the interaction term

margins QC4#QC5, predict(outcome(1))

marginsplot, noci ytitle(Probability of voting Fianna Fail) xtitle(Economy in Ireland over last 5 years has ...) xtitle(, margin(medium)) xlabel(, labsize(vsmall)) title(Adjusted predictions of the interaction term) subtitle(2002) legend(order(2 "Government fault" 1 "Not government fault") cols(1) region(lcolor(none))) scheme(s1mono) subtitle(2002) plotregion(margin(large))  saving(FFinteraction2002, replace)





/*margins for FG*/
*average marginal effect of covariates for voting FG
margins, dydx(QC4 QC5 QC6) predict(outcome(2))

marginsplot, recast(scatter) ytitle(Effects on probability of voting Fine Gael) yline(0, lwidth(vthin) lcolor(red)) xtitle(Effects with respect to) xtitle(, margin(medium)) title(Average Marginal Effects with 95% CIs, justification(right)) legend(cols(1) region(lcolor(none))) xscale(range(1.5 9.5)) scheme(s1mono) subtitle(2002) saving(FGme2002, replace)



*average prediction of the interaction term
margins QC4#QC5, predict(outcome(2))

marginsplot, noci ytitle(Probability of voting Fine Gael) xtitle(Economy in Ireland over last 5 years has ...) xtitle(, margin(medium)) xlabel(, labsize(vsmall)) title(Adjusted predictions of the interaction term) legend(order(2 "Government fault" 1 "Not government fault") cols(1) region(lcolor(none))) scheme(s1mono) subtitle(2002) plotregion(margin(large)) saving(FGinteraction2002, replace)


/*margins for LAB*/
*average marginal effect of covariates for voting LAB

*margins, dydx(QC4 QC5 QC6) predict(outcome(4))

*None of QC4 levels are significant but they screw up the graph with CIs, so QC4 is omitted here.
margins, dydx(QC5 QC6) predict(outcome(4))

marginsplot, recast(scatter) ytitle(Effects on probability of voting Labour) yline(0, lwidth(vthin) lcolor(red)) xtitle(Effects with respect to) xtitle(, margin(medium)) xscale(range(-3 4.5)) title(Average Marginal Effects with 95% CIs, justification(right)) legend(cols(1) region(lcolor(none))) scheme(s1mono) subtitle(2002) saving(LABme2002, replace)

*average prediction of the interaction term
margins QC4#QC5, predict(outcome(4))

marginsplot, noci ytitle(Probability of voting Labour) xtitle(Economy in Ireland over last 5 years has ...) xtitle(, margin(medium)) xlabel(, labsize(vsmall)) title(Adjusted predictions of the interaction term) legend(order(2 "Government fault" 1 "Not government fault") cols(1) region(lcolor(none))) scheme(s1mono) subtitle(2002) plotregion(margin(large)) saving(LABinteraction2002, replace)


/*margins for SF*/
*average marginal effect of covariates for voting SF

margins, dydx(QC4 QC5 QC6) predict(outcome(6))

marginsplot, recast(scatter) ytitle(Effects on probability of voting Sinn Fein) yline(0, lwidth(vthin) lcolor(red)) xtitle(Effects with respect to) xtitle(, margin(medium)) xscale(range(1.5 9.5)) title(Average Marginal Effects with 95% CIs, justification(right)) legend(cols(1) region(lcolor(none))) graphregion(margin(large)) scheme(s1mono) subtitle(2002) saving(SFme2002, replace)

*average prediction of the interaction term
margins QC4#QC5, predict(outcome(6))

marginsplot, noci ytitle(Probability of voting Sinn Fein) xtitle(Economy in Ireland over last 5 years has ...) xtitle(, margin(medium)) xlabel(, labsize(vsmall)) title(Adjusted predictions of the interaction term) legend(order(2 "Government fault" 1 "Not government fault") cols(1) region(lcolor(none))) scheme(s1mono) subtitle(2002) plotregion(margin(large)) saving(SFinteraction2002, replace)




/*2007*/
mlogit QB4CB i.QC4##i.QC5 i.QC6 ffid-pdid if ines==2007 & QB4CB < 8, b(2)

est store e2007tab2


/*margins for FF*/
*average marginal effect of covariates for voting FF

margins, dydx(QC4 QC5 QC6) predict(outcome(1))

marginsplot, recast(scatter) ytitle(Effects on probability of voting Fianna Fail) yline(0, lwidth(vthin) lcolor(red)) xtitle(Effects with respect to) xtitle(, margin(medium)) title(Average Marginal Effects with 95% CIs, justification(right)) legend(cols(1) region(lcolor(none))) xscale(range(1.5 9.5)) scheme(s1mono) subtitle(2007) saving(FFme2007, replace)

*average prediction of the interaction term
margins QC4#QC5, predict(outcome(1))

marginsplot, noci ytitle(Probability of voting Fianna Fail) xtitle(Economy in Ireland over last 5 years has ...) xtitle(, margin(medium)) xlabel(, labsize(vsmall)) title(Adjusted predictions of the interaction term) legend(order(2 "Government fault" 1 "Not government fault") cols(1) region(lcolor(none))) scheme(s1mono) subtitle(2007) plotregion(margin(large)) saving(FFinteraction2007, replace)


/*margins for FG*/
*average marginal effect of covariates for voting FG

margins, dydx(QC4 QC5 QC6) predict(outcome(2))

marginsplot, recast(scatter) ytitle(Effects on probability of voting Fine Gael) yline(0, lwidth(vthin) lcolor(red)) xtitle(Effects with respect to) xtitle(, margin(medium)) title(Average Marginal Effects with 95% CIs, justification(right)) legend(cols(1) region(lcolor(none))) xscale(range(1.5 9.5)) scheme(s1mono) subtitle(2007) saving(FGme2007, replace)

*average prediction of the interaction term
margins QC4#QC5, predict(outcome(2))

marginsplot, noci ytitle(Probability of voting Fine Gael) xtitle(Economy in Ireland over last 5 years has ...) xtitle(, margin(medium)) xlabel(, labsize(vsmall)) title(Adjusted predictions of the interaction term) legend(order(2 "Government fault" 1 "Not government fault") cols(1) region(lcolor(none))) scheme(s1mono) subtitle(2007) plotregion(margin(large)) saving(FGinteraction2007, replace)


/*margins for LAB*/
*average marginal effect of covariates for voting LAB

margins, dydx(QC4 QC5 QC6) predict(outcome(4))

marginsplot, recast(scatter) ytitle(Effects on probability of voting Labour) yline(0, lwidth(vthin) lcolor(red)) xtitle(Effects with respect to) xtitle(, margin(medium))  title(Average Marginal Effects with 95% CIs, justification(right)) legend(cols(1) region(lcolor(none))) xscale(range(1.5 9.5)) scheme(s1mono) subtitle(2007) saving(LABme2007, replace)

*average prediction of the interaction term
margins QC4#QC5, predict(outcome(4))

marginsplot, noci ytitle(Probability of voting Labour) xtitle(Economy in Ireland over last 5 years has ...) xtitle(, margin(medium)) xlabel(, labsize(vsmall)) title(Adjusted predictions of the interaction term) legend(order(2 "Government fault" 1 "Not government fault") cols(1) region(lcolor(none))) scheme(s1mono) subtitle(2007) plotregion(margin(large)) saving(LABinteraction2007, replace)


/*margins for SF*/
*average marginal effect of covariates for voting SF

margins, dydx(QC4 QC5 QC6) predict(outcome(6))

marginsplot, recast(scatter) ytitle(Effects on probability of voting Sinn Fein) yline(0, lwidth(vthin) lcolor(red)) xtitle(Effects with respect to) xtitle(, margin(medium)) xscale(range(1.5 9.5)) title(Average Marginal Effects with 95% CIs, justification(right)) legend(cols(1) region(lcolor(none))) graphregion(margin(large)) scheme(s1mono) subtitle(2007) saving(SFme2007, replace)

*average prediction of the interaction term
margins QC4#QC5, predict(outcome(6))

marginsplot, noci ytitle(Probability of voting Sinn Fein) xtitle(Economy in Ireland over last 5 years has ...) xtitle(, margin(medium)) xlabel(, labsize(vsmall)) title(Adjusted predictions of the interaction term) legend(order(2 "Government fault" 1 "Not government fault") cols(1) region(lcolor(none))) scheme(s1mono) subtitle(2007) plotregion(margin(large)) saving(SFinteraction2007, replace)



/*2011*/

mlogit QB4CBnew i.QC4 i.QC5 i.QC6  ffid-otherid if ines==2011, b(2)


mlogit QB4CB i.QC4##i.QC5 i.QC6 ffid-sfid if ines==2011 & QB4CB < 8, b(2)

est store e2011tab2



/*margins for FF*/
*average marginal effect of covariates for voting FF

margins, dydx(QC5 QC6) predict(outcome(1))

marginsplot, recast(scatter) ytitle(Effects on probability of voting Fianna Fail) xtitle(Effects with respect to) xtitle(, margin(medium)) xscale(range(-3 4.5)) title(Average Marginal Effects with 95% CIs, justification(right)) legend(cols(1) region(lcolor(none))) scheme(s1mono) subtitle(2011) saving(FFme2011, replace)


*average prediction of the interaction term
margins QC4#QC5, predict(outcome(1))

marginsplot, noci ytitle(Probability of voting Fianna Fail) xtitle(Economy in Ireland over last 5 years has ...) xtitle(, margin(medium)) xlabel(, labsize(vsmall)) title(Adjusted predictions of the interaction term) legend(order(2 "Government fault" 1 "Not government fault") cols(1) region(lcolor(none))) scheme(s1mono) subtitle(2011) plotregion(margin(large)) saving(FFinteraction2011, replace)


/*margins for FG*/
*average marginal effect of covariates for voting FG

margins, dydx(QC5 QC6) predict(outcome(2))

marginsplot, recast(scatter) ytitle(Effects on probability of voting Fine Gael) yline(0, lwidth(vthin) lcolor(red)) xtitle(Effects with respect to) xtitle(, margin(medium)) xscale(range(-3 4.5)) title(Average Marginal Effects with 95% CIs, justification(right)) legend(cols(1) region(lcolor(none))) scheme(s1mono) subtitle(2011) saving(FGme2011, replace)


*average prediction of the interaction term
margins QC4#QC5, predict(outcome(2))

marginsplot, noci ytitle(Probability of voting Fine Gael) xtitle(Economy in Ireland over last 5 years has ...) xtitle(, margin(medium)) xlabel(, labsize(vsmall)) title(Adjusted predictions of the interaction term) legend(order(2 "Government fault" 1 "Not government fault") cols(1) region(lcolor(none))) scheme(s1mono) subtitle(2011) plotregion(margin(large)) saving(FGinteraction2011, replace)


/*margins for LAB*/
*average marginal effect of covariates for voting LAB

margins, dydx(QC5 QC6) predict(outcome(4))

marginsplot, recast(scatter) ytitle(Effects on probability of voting Labour) yline(0, lwidth(vthin) lcolor(red)) xtitle(Effects with respect to) xtitle(, margin(medium)) xscale(range(-3 4.5)) title(Average Marginal Effects with 95% CIs, justification(right)) legend(cols(1) region(lcolor(none))) scheme(s1mono) subtitle(2011) saving(LABme2011, replace)


*average prediction of the interaction term
margins QC4#QC5, predict(outcome(4))

marginsplot, noci ytitle(Probability of voting Labour) xtitle(Economy in Ireland over last 5 years has ...) xtitle(, margin(medium)) xlabel(, labsize(vsmall)) title(Adjusted predictions of the interaction term) legend(order(2 "Government fault" 1 "Not government fault") cols(1) region(lcolor(none))) scheme(s1mono) subtitle(2011) plotregion(margin(large)) saving(LABinteraction2011, replace)


/*margins for SF*/
*average marginal effect of covariates for voting SF

margins, dydx(QC5 QC6) predict(outcome(6))

marginsplot, recast(scatter) ytitle(Effects on probability of voting Sinn Fein) yline(0, lwidth(vthin) lcolor(red)) xtitle(Effects with respect to) xtitle(, margin(medium)) xscale(range(-3 4.5)) title(Average Marginal Effects with 95% CIs, justification(right)) legend(cols(1) region(lcolor(none))) scheme(s1mono) subtitle(2011) saving(SFme2011, replace)

*average prediction of the interaction term
margins QC4#QC5, predict(outcome(6))

marginsplot, noci ytitle(Probability of voting Sinn Fein) xtitle(Economy in Ireland over last 5 years has ...) xtitle(, margin(medium)) xlabel(, labsize(vsmall)) title(Adjusted predictions of the interaction term) legend(order(2 "Government fault" 1 "Not government fault") cols(1) region(lcolor(none))) scheme(s1mono) subtitle(2011) plotregion(margin(large)) saving(SFinteraction2011, replace)


graph combine FFme2002.gph FFinteraction2002.gph FFme2007.gph FFinteraction2007.gph FFme2011.gph FFinteraction2011.gph, title(Fianna Fail) cols(2) ysize(8) saving(tab2-FF, replace) scheme(s1mono) iscale(.45)

graph export tab2-FF.pdf, replace


graph combine FGme2002.gph FGinteraction2002.gph FGme2007.gph FGinteraction2007.gph FGme2011.gph FGinteraction2011.gph, title(Fine Gael) cols(2) ysize(8) saving(tab2-FG, replace) scheme(s1mono) iscale(.45)

graph export tab2-FG.pdf, replace


graph combine LABme2002.gph LABinteraction2002.gph LABme2007.gph LABinteraction2007.gph LABme2011.gph LABinteraction2011.gph, title(Labour) cols(2) ysize(8) saving(tab2-LAB, replace) scheme(s1mono) iscale(.45)

graph export tab2-LAB.pdf, replace

graph combine SFme2002.gph SFinteraction2002.gph SFme2007.gph SFinteraction2007.gph SFme2011.gph SFinteraction2011.gph, title(Sinn Fein) cols(2) ysize(8) saving(tab2-SF, replace) scheme(s1mono) iscale(.45)

graph export tab2-SF.pdf, replace




outreg2 [e2002tab2 e2007tab2 e2011tab2] using Table2, stats(coef se) see onecol replace drop(ffid fgid lbid sfid) 


